package com.myproject.thread.pool;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Test {

    private static Executor executor = Executors.newFixedThreadPool(10);
    //private static Executor executor = Executors.newCachedThreadPool();
    public static void main(String[] args) {

        for (int i = 0; i < 20; i++) {
            executor.execute(new Task());
        }

    }

    static class Task implements Runnable{

        @Override
        public void run() {
            String name = Thread.currentThread().getName();
            String[] split = name.split("-");
            String s = split[split.length - 1];
            Integer integer = Integer.valueOf(s);
            if (integer%2==0){
                throw new RuntimeException("偶数报错");
            }
            System.out.println(Thread.currentThread().getName());
        }
    }

}
